According to an aspect of the present invention, there is provided a contrast enhancement method for an image having a plurality of pixels, the method comprising: extracting at least one sub-band image from the image, comprising detail information at a predetermined spatial scale; determining a first gain value for each pixel, based on pixel values of the image or the at least one sub-band image; determining a second gain value for each pixel; modifying the first gain value for each pixel using the respective second gain value; and generating an enhanced image by applying the modified first gain values to respective pixels of one or more sub-band images and combining the result with the image, wherein determining the first gain value for each pixel comprises: estimating a dynamic range of the pixel values in a neighbourhood of that pixel; and setting the first gain value in inverse relation to the dynamic range, and wherein determining the second gain value for each pixel comprises: estimating a probability distribution of the pixel values in the neighbourhood; and determining the second gain value based on the amplitude of the peak of the probability distribution.
The or each sub-band image contains detail information of the input image. That is, low frequencies have been attenuated such that the frequency-content remaining is high-pass or band-pass. A sub-band image could therefore be derived by linear filtering with a suitable band-pass or high-pass filter. However, it will be understood that a variety of other linear or non-linear methods can also be used to extract or emphasize spatial variations in the pixel function and arrive at a suitable sub-band image.
The gain value represents an enhancement factor, to be applied to one or more sub-band images in order to emphasize detail information in the image and thereby enhance the contrast. The one or more sub-band images to which the gain is applied may be the same as or different from the at least one sub-band image from which the gain values can be derived. The gain can be applied by a variety of operations, including, but not limited to addition, linear scaling, and higher-order operations. Likewise, the result of applying the gain values may be combined with the input image by a variety of suitable linear or non-linear arithmetic operations.
The gain value is set in inverse relation to the dynamic range of the pixels in a local neighbourhood. This means that pixels in areas having a wide dynamic range receive relatively less enhancement than pixels in areas having a narrow dynamic range. This can prevent over-enhancement, by restricting the enhancement factor in areas of the image which already have a high degree of contrast.
The first gain value for each pixel is preferably determined based on pixel values of the at least one sub-band image.
It may be beneficial to determine the dynamic range (and hence the gain value) from the sub-band image, instead of directly from the input image. Low-frequencies are attenuated in the sub-band image. Therefore, slow variations (gentle gradients) in the pixel function have been substantially removed. As a result, the sub-band image may better capture the dynamic range of the detail information, in particular.
The method further comprises, before the step of generating the enhanced image: determining a second gain value for each pixel; and modifying the first gain value for each pixel using the respective second gain value, wherein determining the second gain value for each pixel comprises: estimating a probability distribution of the pixel values in the neighbourhood; and determining the second gain value based on the amplitude of the peak of the probability distribution.
This method provides a more sophisticated determination of the gain. The first gradient value takes into account the overall dynamic range, while the second gain value takes into account a measure of the sharpness of the probability distribution. A low amplitude peak in the probability density function corresponds to a broad variation in pixel values; a peak of high amplitude corresponds to a relatively homogenous distribution. The peak amplitude and the dynamic range can be interrelated to some extent. For example, a relatively low peak corresponding to a broad distribution will typically also have a relatively wider dynamic range. However, in general these two aspects can vary independently, because the shape of the underlying distribution can be complex. The present inventors have recognised that it is advantageous to set the enhancement factor (gain) based on both. For example, each gain value can modulate the other, so that if either the first or second gain indicates that contrast should not be enhanced, the resulting combined gain will be set low.
The second gain value is preferably determined such that: a maximum gain is set when the amplitude of the peak is at an intermediate level; a minimum gain is set when the amplitude of the peak is at a maximum level; and an intermediate gain value is set when the amplitude of the peak is at a minimum level.
According to the second gain value, maximum contrast enhancement should be applied when there is a significant variation to be enhanced. In this case, the peak of the distribution will have intermediate amplitude. This corresponds, for example, to a bi-modal distribution. Totally homogenous areas of the image will give rise to a relatively large peak in the distribution. These areas should receive minimal enhancement, because there is no detail to emphasize. A flat distribution will have the lowest possible peak amplitude, and will correspond to an area of the image which already has a relatively high level of detail and contrast. Contrast enhancement in such regions should be moderate.
The estimate of the probability distribution may comprise a histogram.
The dynamic range of the pixel values may be estimated from the probability distribution.
For example, in the case that the probability distribution is estimated by means of a histogram, the dynamic range can be estimated by examining the distance between the first and last occupied bins.
Also provided is a computer program, comprising computer program code means adapted to perform all the steps of any of the method described above when said program is run on a computer. The computer program may be embodied on a computer-readable medium.
The invention further provides image processing apparatus for contrast enhancement of an image having a plurality of pixels, the apparatus comprising: filtering means, adapted to extract at least one sub-band image from the image, said at least one sub-band image comprising detail information at a predetermined spatial scale; first gain determination means, adapted to determine a first gain value for each pixel, based on pixel values of the image or the at least one sub-band image; and image enhancement means, adapted to generate an enhanced image by applying the first gain values to respective pixels of one or more sub-band images and combining the result with the image, wherein the first gain determination means are adapted to determine the first gain value for each pixel by: estimating a dynamic range of the pixel values in a neighbourhood of that pixel; and setting the first gain value in inverse relation to the dynamic range.
The apparatus further comprises: second gain determination means, adapted to determine a second gain value for each pixel; and gain combination means, adapted to modify the first gain value using the second gain value, wherein the second gain determination means are adapted to: estimate a probability distribution of the pixel values in the neighbourhood of the pixel; and determine the second gain value based on the amplitude of the peak of the probability distribution.